import { createSearchParams, Link, useLocation, useNavigate, useSearchParams } from 'umi';
import styles from './index.less';

export default function Page() {
  const navigate = useNavigate();
  const [searchParams, setSearchParams] = useSearchParams();
  const a = searchParams.get('a');
  const b = searchParams.get('b');
  const location = useLocation();
  console.log(location.state)
  return (
    <div className="main">
      <h1 className={styles.title}>Page index</h1>
      <div>
        <Link to="../">首页</Link> ｜
        <Link to="../desc">详情页</Link>
      </div>
      <hr />
      <p>useSearchParams --- a:{a}--b:{b}</p>
      <button onClick={() => {
        setSearchParams(createSearchParams({ a: '123', b: '456' }));
      }}>Change SearchParams</button>
      <hr />
    </div>
  );
}
